<div ng-controller="FapiaoSearchCtrl as vm">
  <h1 class="page-title">搜索发票</h1>
  <div class="well">
    <form method='POST' action='/api/invoice/export'>
    <div class="form-horizontal" >
      <fieldset>
        <div class="control-group" ng-if="vm.userRole=='admin'">
              <label class="control-label">选择企业会员</label>
              <div class="controls">
                <select class="input-large" name="shipperId" ng-model="vm.fapiao.shipperId">
                  <option value="0">全部</option>
                    <option ng-repeat="option in shippers" value="{{option.id}}">{{option.enterpriseName}}</option>
                </select>
                <p class="help-block"></p>
              </div>
            </div>
            <input type="hidden" ng-if="vm.userRole=='shipper'" value="{{vm.userId}}" name="shipperId" />
              <input type="hidden" ng-if="vm.userRole=='carrier'" value="0" name="shipperId" />
          <div class="control-group">
            <!-- Text input-->
            <label class="control-label">发票申请号</label>
            <div class="controls">
              <input type="text" name="applicationId" ng-model="vm.fapiao.applicationId"  class="input-xlarge search-query">
              <p class="help-block"></p>
            </div>
          </div>
          <div class="control-group">
            <!-- Search input-->
            <label class="control-label">发票号</label>
            <div class="controls">
              <input type="text" name="invoiceNumber" ng-model="vm.fapiao.invoiceNumber" class="input-xlarge search-query">
              <p class="help-block"></p>
            </div>
          </div>
          <div class="control-group">
                  <label class="control-label">状态</label>
                  <div class="controls">
                      <select  ng-model="vm.status">
                          <option value="0">全部</option>
                          <option value="2">申请中</option>
                          <option value="3">已完成</option>
                      </select>
                      <p class="help-block"></p>
                  </div>
              </div>
              <div class="control-group">
            <!-- Text input-->
            <label class="control-label">搜索起始日期</label>
            <div class="controls">
              <input id="startDate" placeholder="搜索起始日期" class="laydate-icon" onclick="laydate()" >
              <p class="help-block"></p>
            </div>
          </div>
          <div class="control-group">
            <!-- Search input-->
            <label class="control-label">搜索结束日期</label>
            <div class="controls">
              <input id="endDate" placeholder="搜索结束日期" class="laydate-icon" onclick="laydate()" >
              <p class="help-block"></p>
            </div>
          </div>
      </fieldset>
      <div class="control-group">
        <label class="control-label"></label>
        <!-- Button -->
        <div class="controls">
          <a class="btn btn-primary" ng-click="vm.searchFapiao()">搜索</a>
        </div>
      </div>
    </div>
  <p ng-show="vm.noRecord">没有找到符合条件的发票！</p>
    <div class="table-responsive" ng-show="vm.fapiaos.length>0">
      <input name="status" ng-value="vm.status!=0? vm.status:''" hidden/>
            <button class="btn" type="submit">导出结果</button>
      <table class="table table-striped table-bordered">
        <thead>
          <tr>
            <th>开票申请号</th>
            <th>发票号</th>
            <th ng-show="vm.userRole == 'admin'">申请人</th>
            <th>企业会员</th>
            <th>总金额</th>
            <th>运单数</th>
            <th>状态</th>
            <th>操作</th>
          </tr>
        </thead>
        <tbody>
          <tr ng-repeat="fapiao in vm.fapiaos">
            <td><a ng-click="vm.viewDetail(fapiao.id)" >{{fapiao.applicationId}}</a></td>
            <td>{{fapiao.invoiceNumber}}</td>
            <td ng-show="vm.userRole=='admin'">{{fapiao.shipper.contact.name}}</td>
            <td>{{fapiao.carrier.contact.name}}</td>
            <td>{{fapiao.price}}</td>
            <td>{{fapiao.orderCount}}</td>
            <td>{{fapiao.status==2? '申请中':'已完成'}}</td>
            <td>
               <a ng-show="fapiao.status==2" class="btn btn-primary btn-mini" ng-click="vm.viewDetail(fapiao.id)">查看</a>
               <a ng-show="fapiao.status==3" class="btn btn-primary btn-mini" ng-click="vm.viewDetailActual(fapiao.id)">查看</a>
            </td>
          </tr>
          
        </tbody>
      </table>
          <div class="pagination pagination-centered">
        <ul>
         <li ng-class="vm.firstPage? 'disabled':''" ng-switch="vm.firstPage">
         <a ng-switch-when="false" ng-click="vm.loadPage(vm.currentPage-1)" >&laquo;</a>
         <a ng-switch-when="true" >&laquo;</a>
         </li>
          <li ng-repeat="me in vm.pages" ng-class="me==vm.currentPage? 'active':''" ng-switch="me==vm.currentPage">
            <a ng-switch-when="false" ng-click="vm.loadPage(me)" >{{me}}</a>
            <a ng-switch-when="true" >{{me}}</a>
            </li>
          <li ng-class="vm.lastPage? 'disabled':''" ng-switch on="vm.lastPage">
          <a ng-switch-when="false" ng-click="vm.loadPage(vm.currentPage+1)">&raquo;</a>
          <a ng-switch-when="true" >&raquo;</a>
          </li>
        </ul>
      </div>
    </div>
  </div>
</div>
</div>